<template>
  <div class="commodity-card">
    <div class="show-img">
      <img src="@/assets/Bitmap@3x.png" alt="" />
    </div>
    <div class="commodity-title">{{ product.name }}</div>
    <div class="commodity-tag">{{ product.price }}</div>
    <div class="commodity-price">
      <div class="price">
        {{ product.lastPrice }}
        <div class="right">{{ product.useNum }}</div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ProductItemType } from '../init-data-types'

interface PropsType {
  product: ProductItemType
}

defineProps<PropsType>()
</script>

<style lang="scss" scoped>
.commodity-card {
  display: inline-block;
  width: 170px;
  height: 212px;
  margin: 10px 0 0 12px;
  overflow: hidden;
  background: #fff;
  border-radius: 5px;
  .show-img {
    overflow: hidden;
    height: 136px;
    position: relative;
    &::after {
      content: '包邮';
      font-size: 11px;
      color: #fff;
      padding: 3px 6px;
      background: linear-gradient(90deg, #ff9a3c, #ff611c);
      border-radius: 2px;
      position: absolute;
      right: 5px;
      top: 12px;
    }
    img {
      width: 167.5px;
      height: 136px;
      transform: scale(1.3);
    }
  }

  .commodity-title {
    text-overflow: ellipsis;
    overflow: hidden;
    word-break: break-all;
    white-space: nowrap;
    font-size: 14px;
    padding: 5px 10px 0 10px;
  }
  .commodity-tag {
    color: #ff6737;
    font-size: 14px;
    line-height: 14px;
    padding: 8px 10px 0 10px;
  }
  .commodity-price {
    line-height: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px 12px 10px;
    font-size: 12px;
    .price {
      color: #999999;
      text-decoration: line-through;
      .right {
        display: inline-block;
        padding-left: 5px;
        text-decoration: none;
      }
    }
  }
}
</style>
